#匹配函数
#数组中的0 = mesurement，1 = field，2 = title，3 = content
def match_type_id(measurement,field):
    if field == 'usage_guest':
        return 1
    elif field == 'usage_user':
        return 2
    elif field == 'usage_system':
        return 3
    elif field == 'usage_iowait':
        return 4
    elif field == 'usage_active':
        return 5
    elif field == 'used_percent':
        if measurement == 'mem':
            return 6
        elif measurement == 'disk':
            return 9
    elif field == 'swap_used_percent':
        return 7
    elif field == 'available_percent':
        return 8
    elif field == 'inodes_used_percent':
        return 10
    elif field == 'io_time':
        return 11
    elif field == 'err_in':
        return 12
    elif field == 'err_out':
        return 13
    elif field == 'receive':
        return 14
    elif field == 'total':
        return 15
    elif field == 'pct_zombie':
        return 16
    elif field == 'load1':
        return 17
    elif field == 'load5':
        return 18
    elif field == 'load15':
        return 19

def match_field(type_id):
    if type_id >= 1 and type_id <= 5:
        if type_id == 1:
            return ['cpu','usage_guest','cpu虚拟化运行其他操作系统的时间占比过高','cpu虚拟化运行其他操作系统的时间占比超过阈值']
        elif type_id == 2:
            return ['cpu','usage_user','cpu用户态时间占比过高','cpu用户态时间占比超过阈值']
        elif type_id == 3:
            return ['cpu','usage_system','cpu内核态时间占比过高','cpu内核态时间占比超过阈值']
        elif type_id == 4:
            return ['cpu','usage_iowait','cpu空闲等待i/o操作完成时间过高','cpu空闲等待i/o操作完成时间占比超过阈值']
        elif type_id == 5:
            return ['cpu','usage_active','cpu使用率过高','cpu使用率超过阈值']
    elif type_id <= 8:
        if type_id == 6:
            return ['mem','used_percent','内存使用占比过高','内存使用占比超过阈值']
        elif type_id == 7:
            return ['mem','swap_used_percent','内存swap占比过高','内存swap占比超过阈值']
        elif type_id == 8:
            return ['mem','available_percent','内存可用占比过低','内存可用占比低于阈值']
    elif type_id <= 10:
        if type_id == 9:
            return ['disk','used_percent','磁盘使用占比过高','磁盘使用占比超过阈值']
        elif type_id == 10:
            return ['disk','inodes_used_percent','磁盘inode占比过高','磁盘inode占比超过阈值']
    elif type_id == 11:
        return['diskio','io_time','磁盘io时间占比过高','磁盘io时间占比超过阈值']
    elif type_id <= 14:
        if type_id == 12:
            return ['net','err_in','网络接收错误包占比过高','网络接收错误包占比超过阈值']
        elif type_id == 13:
            return ['net','err_out','网络发送错误包占比过高','网络发送错误包占比超过阈值']
        elif type_id == 14:
            return ['net','receive','网络接收占比过高','网络接收占比超过阈值']
    elif type_id <= 16:
        if type_id == 15:
            return ['processes','total','进程总数占比过高','进程总数占比超过阈值']
        elif type_id == 16:
            return ['processes','pct_zombie','僵尸进程占比过高','僵尸进程占比超过阈值']
    elif type_id <= 19:
        if type_id == 17:
            return ['system','load1','平均一分钟负载过高','平均一分钟负载超过阈值']
        elif type_id == 18:
            return ['system','load5','平均五分钟负载过高','平均五分钟负载超过阈值']
        elif type_id == 19:
            return ['system','load15','平均十五分钟负载过高','平均十五分钟负载超过阈值']
